
layui.use(['form','layer','laydate','table'],function(){
	var $ = layui.jquery;
	var navList = null;
	//alert("yw"); //yw debug
	if(navList == null){
		$.ajax({ //yw 从后台获取学校数据，填充前端的学校下拉框
			url:'/school/queryAllSchoolBuild',
			dataType:'json',
			async:false,
			type:'post',
			success:function(data){
				navList = data;
				navRender(navList);
			}
		})
	}else{
		navRender(navList);
	}
	
	function navRender(navList){
		var navData = '';
		for(let i=0;i<navList.length;i++){
			navData+= "<li class='nav-item'><a href='javascript:;'><span>"+navList[i].p+"</span><i class='layui-icon nav-icon'>&#xe625;</i></a><ul>"
			for(let w=0;w<navList[i].c.length;w++){
				navData+="<li><a name='t1' schoolId="+navList[i].pid+" tBuildName="+navList[i].c[w]+" tBuildID="+navList[i].cid[w]+" href=''>&nbsp;&nbsp;<span>"+navList[i].c[w]+"</span></a></li>"
			}
			navData+="</ul></li>"
		}
		//console.log(navData)
		$('#aat').html(navData)
	}
	$(function(){
		// nav收缩展开
		$('#aat').on('click','.nav-item>a',function(){
			if (!$('.nav').hasClass('nav-mini')) {
				if ($(this).next().css('display') == "none") {
					//展开未展开
					$('.nav-item').children('ul').slideUp(300);
					$(this).next('ul').slideDown(300);
					$(this).parent('li').addClass('nav-show').siblings('li').removeClass('nav-show');
				}else{
					//收缩已展开
					$(this).next('ul').slideUp(300);
					$('.nav-item.nav-show').removeClass('nav-show');
				}
			}
		});
		// 标志点击样式
		$('#aat').on('click','.nav-item>ul>li',function(){
			$('.nav-item>ul>li').css('background','none')
			$(this).css('background','lightgray')
		  	//$(this).siblings().css('background','none')
		})
		
	});

}); //yw 最后一行对应layui.use(['form','layer','laydate','table'],function(){
